﻿namespace TC
{
    public enum EComparison
    {
        GREATER,
        GREATER_EQUAL,
        LESS,
        LESS_EQUAL,
        EQUAL,
        NOT_EQUAL,
    }

    public class CompareInt : VariableNode
    {
        //public ValueInput<EComparison> operate;
        public EComparison operate;
        public ValueInput<int> a;
        public ValueInput<int> b;

        public ValueOutput<bool> value;

        public override void OnCreate()
        {
            base.OnCreate();

            //operate = this.AddValueInPort<EComparison>("operate");
            a = this.AddValueInPort<int>("a");
            b = this.AddValueInPort<int>("b");
            value = this.AddValueOutPort<bool>("value", ()=>
            {
                //EComparison op = operate.Value;
                EComparison op = operate;
                switch (op)
                {
                    case EComparison.GREATER:
                        return a.Value > b.Value;
                    case EComparison.GREATER_EQUAL:
                        return a.Value >= b.Value;
                    case EComparison.LESS:
                        return a.Value < b.Value;
                    case EComparison.LESS_EQUAL:
                        return a.Value <= b.Value;
                    case EComparison.EQUAL:
                        return a.Value == b.Value;
                    case EComparison.NOT_EQUAL:
                        return a.Value != b.Value;
                }
                return false;
            });
        }
    }
}
